<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx">
          <template #warehouseName>
            <el-select v-model="ctx.filter.warehouseId">
              <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['core:warehouse:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['core:warehouse:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['core:warehouse:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>
      </template>
      <template #type="scope">
        {{ ctx.other.getTypeName(scope.row.type) }}
      </template>
      <template #disabled="scope">
        <el-switch v-model="scope.row.disabled" :active-value="false" :inactive-value="true"
          @change="ctx.other.statusChanged(scope.row)" />
      </template>
      <template #operation="scope">
        <el-button type="primary" v-hasPermit="['core:warehouse:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button v-hasPermit="['core:warehouse:del']" type="danger" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="800px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-form-item label="单号" prop="originalNo">
              <el-input v-model="ctx.editData.originalNo" placeholder="请输入单号" />
            </el-form-item>
            <el-form-item label="仓库" prop="warehouseId">
              <el-select v-model="ctx.editData.warehouseId" placeholder="请选择仓库" @change="ctx.other.handleWarehouse">
                <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="项目名称" prop="project">
              <el-input v-model="ctx.editData.project" placeholder="请输入项目名称" />
            </el-form-item>
            <el-form-item label="状态" prop="status">
              <el-input v-model="ctx.editData.status" placeholder="请输入状态" />
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" v-model="ctx.editData.remark" />
            </el-form-item>
            <!-- <el-table :data="ctx.editData.orderGoodsList">
                <el-table-column prop="barCode" label="商品编码">
                  <template #default="scope">
                    <el-input v-model="scope.row.barCode" />
                  </template>
                </el-table-column>
                <el-table-column prop="name" label="Name" width="180" />
                <el-table-column prop="address" label="Address" />
              </el-table> -->
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./requirement" />

<style lang="scss" scoped>

</style>
